package org.bbs.demo.reply.dao;


import org.apache.ibatis.annotations.*;
import org.bbs.demo.reply.dto.UserRReplyLikeDto;
import org.bbs.demo.reply.dto.UserReplyLikeDto;

@Mapper
public interface LikeDao {
    @Select("select r_id from bbsreply where r_id = #{r_id}")
    public String findRid(String r_id);

    @Select("select storey_r_id from storey_reply where storey_r_id = #{storey_r_id}")
    public String findStoreyRid(String storey_r_id);

    @Update("update bbsreply set r_likes = r_likes - 1 where r_id = #{r_id}")
    public int subRLikes(String r_id);

    @Update("update storey_reply set s_r_likes = s_r_likes - 1 where storey_r_id = #{storey_r_id}")
    public int subStoreyRLikes(String storey_r_id);

    @Update("update bbsreply set r_likes = r_likes + 1 where r_id = #{r_id}")
    public int addRLikes(String r_id);

    @Update("update storey_reply set s_r_likes = s_r_likes + 1 where storey_r_id = #{storey_r_id}")
    public int addStoreyRLikes(String storey_r_id);

    @Select("select * from user_reply_likes where user_id = #{user_id} and r_id = #{r_id}")
    public UserReplyLikeDto findURLikes(UserReplyLikeDto userreplylikedto);

    @Select("select * from user_rreply_likes where user_id = #{user_id} and storey_r_id = #{storey_r_id}")
    public UserRReplyLikeDto findURRLikes(UserRReplyLikeDto userrreplylikedto);

    @Delete("delete from user_reply_likes where user_id = #{user_id} and r_id = #{r_id}")
    public int deleteURLikes(UserReplyLikeDto userreplylikedto);

    @Delete("delete from user_rreply_likes where user_id = #{user_id} and storey_r_id = #{storey_r_id}")
    public int deleteURRLikes(UserRReplyLikeDto userrreplylikedto);

    @Insert("insert into user_reply_likes (user_id,r_id) values (#{user_id},#{r_id})")
    public int addURLikes(UserReplyLikeDto userreplylikedto);

    @Insert("insert into user_rreply_likes (user_id,storey_r_id) values (#{user_id},#{storey_r_id})")
    public int addURRLikes(UserRReplyLikeDto userrreplylikedto);
}
